/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author server s
 */
@Entity
@Table(name = "Interviews")
@NamedQueries({
    @NamedQuery(name = "Interviews.findAll", query = "SELECT i FROM Interviews i"),
    @NamedQuery(name = "Interviews.findByVacancyID", query = "SELECT i FROM Interviews i WHERE i.interviewsPK.vacancyID = :vacancyID"),
    @NamedQuery(name = "Interviews.findByApplicantID", query = "SELECT i FROM Interviews i WHERE i.interviewsPK.applicantID = :applicantID"),
    @NamedQuery(name = "Interviews.findByEmpNo", query = "SELECT i FROM Interviews i WHERE i.employees.empNo = :empNo AND i.inStatus = 0 "),
    @NamedQuery(name = "Interviews.findByApplicants", query = "SELECT i FROM Interviews i WHERE i.applicants.appStatus = 2 and i.inStatus = 2 "),
    @NamedQuery(name = "Interviews.countByEmpNo", query = "SELECT count(i) FROM Interviews i WHERE i.employees.empNo = :empNo AND i.inStatus=0"),
    @NamedQuery(name = "Interviews.countStatus", query = "SELECT count(i) FROM Interviews i WHERE i.inStatus= :status"),
    @NamedQuery(name = "Interviews.countByIdVacancy", query = "SELECT count(i) FROM Interviews i WHERE i.inStatus= :status AND i.vacances.vacancyID =:vacancyID"),
    @NamedQuery(name = "Interviews.findIdVacancyInterviews", query = "SELECT i FROM Interviews i WHERE i.vacances.vacancyID = :vacancyID and i.inStatus = 0"),
    @NamedQuery(name = "Interviews.findStatusByAppID", query = "UPDATE Interviews i SET i.inStatus =3  WHERE i.applicants.applicantID = :applicantID AND i.inStatus = 0"),
    @NamedQuery(name = "Interviews.countEmpNo", query = "SELECT i FROM Interviews i WHERE i.employees.empNo = :empNo AND i.inStatus=0"),
    @NamedQuery(name = "Interviews.findStatus", query = "SELECT i FROM Interviews i WHERE i.inStatus= :status"),
    @NamedQuery(name = "Interviews.findByScheduleDate", query = "SELECT i FROM Interviews i WHERE i.scheduleDate = :scheduleDate"),
    @NamedQuery(name = "Interviews.findByAttachedDate", query = "SELECT i FROM Interviews i WHERE i.attachedDate = :attachedDate"),
    @NamedQuery(name = "Interviews.findByStartTime", query = "SELECT i FROM Interviews i WHERE i.startTime = :startTime"),
    @NamedQuery(name = "Interviews.findByEndTime", query = "SELECT i FROM Interviews i WHERE i.endTime = :endTime"),
    //@NamedQuery(name = "Interviews.findAppIDAndVaID", query = "SELECT i FROM Interviews i WHERE i.interviewsPK.applicantID=:applicantID AND i.interviewsPK.vacancyID=:vacancyID"),
    @NamedQuery(name = "Interviews.findByCommand", query = "SELECT i FROM Interviews i WHERE i.command = :command"),
    @NamedQuery(name = "Interviews.findByInStatus", query = "SELECT i FROM Interviews i WHERE i.inStatus = :inStatus"),
    @NamedQuery(name = "Interviews.findAllInter", query = "SELECT i FROM Interviews i WHERE i.employees.empNo = :empNo AND i.inStatus = 0 AND i.scheduleDate = :today")
})
public class Interviews implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected InterviewsPK interviewsPK;
    @Column(name = "ScheduleDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date scheduleDate;
    @Column(name = "AttachedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date attachedDate;
    @Column(name = "StartTime")
    private String startTime;
    @Column(name = "EndTime")
    private String endTime;
    @Column(name = "Command")
    private String command;
    @Basic(optional = false)
    @Column(name = "InStatus")
    private int inStatus;
    @JoinColumn(name = "VacancyID", referencedColumnName = "VacancyID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Vacances vacances;
    @JoinColumn(name = "EmpNo", referencedColumnName = "EmpNo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Employees employees;
    @JoinColumn(name = "ApplicantID", referencedColumnName = "ApplicantID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Applicants applicants;

    public Interviews() {
    }

    public Interviews(InterviewsPK interviewsPK) {
        this.interviewsPK = interviewsPK;
    }

    public Interviews(InterviewsPK interviewsPK, int inStatus) {
        this.interviewsPK = interviewsPK;
        this.inStatus = inStatus;
    }

    public Interviews(String vacancyID, String applicantID, String empNo) {
        this.interviewsPK = new InterviewsPK(vacancyID, applicantID, empNo);
    }

    public Interviews(Vacances va, Employees em, Applicants app) {
        this.vacances = va;
        this.employees = em;
        this.applicants = app;
    }

    public InterviewsPK getInterviewsPK() {
        return interviewsPK;
    }

    public void setInterviewsPK(InterviewsPK interviewsPK) {
        this.interviewsPK = interviewsPK;
    }

    public Date getScheduleDate() {
        return scheduleDate;
    }

    public void setScheduleDate(Date scheduleDate) {
        this.scheduleDate = scheduleDate;
    }

    public Date getAttachedDate() {
        return attachedDate;
    }

    public void setAttachedDate(Date attachedDate) {
        this.attachedDate = attachedDate;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public int getInStatus() {
        return inStatus;
    }

    public String getCommand() {
        return command;
    }

    public void setCommand(String command) {
        this.command = command;
    }

    public void setInStatus(int inStatus) {
        this.inStatus = inStatus;
    }

    public Vacances getVacances() {
        return vacances;
    }

    public void setVacances(Vacances vacances) {
        this.vacances = vacances;
    }

    public Employees getEmployees() {
        return employees;
    }

    public void setEmployees(Employees employees) {
        this.employees = employees;
    }

    public Applicants getApplicants() {
        return applicants;
    }

    public void setApplicants(Applicants applicants) {
        this.applicants = applicants;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (interviewsPK != null ? interviewsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Interviews)) {
            return false;
        }
        Interviews other = (Interviews) object;
        if ((this.interviewsPK == null && other.interviewsPK != null) || (this.interviewsPK != null && !this.interviewsPK.equals(other.interviewsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bean.entity.Interviews[interviewsPK=" + interviewsPK + "]";
    }
}
